package com.hd.trans.db.bean;

import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.chad.library.adapter.base.entity.node.BaseNode;
import com.hd.trans.common.Constants;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * Author:  yang
 * Date:    2020/01/02 14:50
 * Desc:    语言类分组
 */
public class LanguageGroup extends BaseNode implements MultiItemEntity {


    private String name;


    private List<BaseNode> items;

    public LanguageGroup() {
    }

    public LanguageGroup(String name) {
        this.name = name;
    }

    @Override
    public int getItemType() {
        return Constants.LevelType.GROUP;
    }

    @Override
    public List<BaseNode> getChildNode() {
        return items;
    }

    public void setItems(List<BaseNode> items) {
        this.items = items;
    }

    public void addItem(HuDunLanguage item) {
        if (items == null) {
            items = new ArrayList<>();
        }
        items.add(item);
    }

    public void clearItems() {
        if (null != items) items.clear();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        LanguageGroup that = (LanguageGroup) o;
        return Objects.equals(name, that.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }


}
